/* 1.require是什么?
    node模块系统的模块加载方法 */


/*  
    fs是什么?
        node环境提供的扩展模块(file system)文件系统模块 
    

*/
 let arr=[
    {
        name:"01.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"02.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"03.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    },
    {
        name:"04.txt",
        list:["aaa","bbb","ccc","ddd","eee"]
    }
    
 ];
 const fs = require("fs");
 for(let i=0;i<arr.length;i++){
    let fileData=arr[i];
    let fileName=fileData.name;
    let fileList=fileData.list;
    // fs.appendFileSync(path,data);//同步将数据追加到文件中
    // path:文件路径
    // data:string类型
    // let obj={a:100};
    // fs.appendFileSync(`./txt/${fileName}`,obj);
    // fs.appendFileSync(`./txt/${fileName}`,fileList);

    // fileList.forEach((item,i)=>{
    //     // console.log(item,i);
    //     fs.appendFileSync(`./txt/${fileName}`,`\n${i+1}:${item}\n`);
    // });

    fs.appendFileSync(`./txt/${fileName}`,fileList.join("\n"));
 }